#include<iostream>
#include"main.h"

using namespace std;

int main()
{
    system("chcp 65001");
    printf("请输入内存大小:");
    int x;
    cin>>x;
    best_fit_algorithm BFA(x);
    while(1)
    {
        printf("1.申请分区\n");
        printf("2.释放分区\n");
        printf("3.输出分区情况\n");
        printf("0.结束操作\n");
        printf("请输入操作符：");
        int x;
        cin>>x;
        if(x==0)
        {
            break;
        }
        else if(x==1)
        {
            printf("请输入申请空间大小:");
            unsigned long long size;
            cin>>size;
            BFA.add_use(size);
        }
        else if(x==2)
        {
            printf("请输入释放分区起始地址和空间大小：");
            unsigned long long start_address,size;
            cin>>start_address>>size;
            BFA.release_used(start_address,size);
        }
        else if(x==3)
        {
            BFA.show();
        }
        std::cout<<std::endl;
    }
}
